# -*- coding:utf-8 -*-
"""
Created on 2009-10-28

@author: Qiu wenfeng
"""
import scipy

def neumannboundcond(f):
    '''
    Make a function satisfy Neumann boundary condition
    '''
    nrow, ncol = f.shape
    g=f
    g[0, 0]=g[2,2]
    g[0, ncol-1]=g[2,ncol-3]
    g[nrow-1, 0]=g[nrow-3,0]
    g[nrow-1,ncol-1]=g[nrow-3, nrow-3]
    
    g[0, 1:-2]=g[2,1:-2]
    g[nrow-1,1:-2]=g[nrow-3, 1:-2]
    
    g[1:-2, 0]=g[1:-2, 2]
    g[1:-2, ncol-1]=g[1:-2, ncol-3]
    
    return g
